# -*- mode: python ; coding: utf-8 -*-
import os
from PyInstaller.building.build_main import TOC
from PyInstaller.utils.hooks import collect_all

datas = []
binaries = []
hiddenimports = []

for pkg in ('numpy', 'pandas'):
    pkg_datas, pkg_binaries, pkg_hiddenimports = collect_all(pkg)
    datas += pkg_datas
    binaries += pkg_binaries
    hiddenimports += pkg_hiddenimports

a = Analysis(
    ['main.py'],
    pathex=[],
    binaries=[],
    datas= datas+[
        # data 还是走默认 datas，会被打进 _internal
        ('data/MPN-IPN.xlsx', 'data'),
        ('data/DataChange.xlsx', 'data'),
        ('data/file_path.json', 'data'),
    ],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
)

pyz = PYZ(a.pure)

exe = EXE(
    pyz,
    a.scripts,
    [],
    exclude_binaries=True,
    name='main-v2.2.1',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    version='version_info.txt',
    icon=['UI\\icon002.ico'],
)

# 单独列出 UI 下的文件，复制到输出目录 UI 子目录
ui_files = [
    ('UI/img4-1080.png', 'UI/img4-1080.png', 'DATA'),
    ('UI/img2-1080.png', 'UI/img2-1080.png', 'DATA'),
    ('UI/logo002.png', 'UI/logo002.png', 'DATA'),
    ('UI/icon002.ico', 'UI/icon002.ico', 'DATA'),
    ('UI/logo1.png', 'UI/logo1.png', 'DATA'),
    ('UI/logo4.png', 'UI/logo4.png', 'DATA'),
    ('UI/logo5.png', 'UI/logo5.png', 'DATA'),
]


coll = COLLECT(
    exe,
    a.binaries,
    a.datas,
    ui_files,  # 这里直接加进去
    strip=False,
    upx=True,
    upx_exclude=[],
    name='main-v2.2.1',
)
